<template>
  <div class="photoDialog">
    <div v-if="imgList.length === 0"  class="proInfo">暂无图片</div>
    <div v-else>
      <div class="imgList">
        <img class="arrow_l"  @click="arrowClick(-1)" src="~@/assets/img/arrow.png">
        <div class="proInfo">
          <img class="proImg" :src="imgList[listFlag]" alt="">
        </div>
        <img class="arrow_r" @click="arrowClick(1)" src="~@/assets/img/arrow.png">
      </div>
      <div class="indexList">
        <div :class="i-1==listFlag?'indexItem active':'indexItem'" v-for="i in imgList.length" :key="i" @click="listFlag=i-1">{{i}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    imgList: Array
  },
  data () {
    return {
      flag: false,
      listFlag: 0
    }
  },
  methods: {
    // 图片列表移动
    arrowClick (i) {
      console.log(this.listFlag)
      if (i > 0) {
        if (this.listFlag === this.imgList.length - 1) {
          return this.$message('没有更多的图片了!')
        }
      } else {
        if (this.listFlag === 0) {
          return this.$message('没有更多的图片了!')
        }
      }
      this.listFlag += i
    }
  }
}
</script>

<style lang="scss">
.photoDialog{
  .el-dialog__header{
    padding: 0;
  }
  .title{
    height: 48px;
    background: #F9F9F9;
    border-radius: 8px 8px 0px 0px;
    font-size: 16px;
    font-family: Arial;
    font-weight: bold;
    line-height: 48px;
    color: #7A7A7A;
    padding-left: 24px;
  }
  .imgList{
    display: flex;
    align-items: center;
    justify-content: space-around;
    .proInfo{
      .date{
        font-size: 12px;
        font-family: ArialMT;
        color: #8E8E8E;
        margin-bottom: 13px;
        display: flex;
        align-items: center;
        .cy{
          width: 10px;
          height: 10px;
          background: #8E8E8E;
          border-radius: 50%;
          margin-right: 5px;
        }
      }
      .proImg{
        width: 563px;
        height: 563px;
      }
    }
    .arrow_l,.arrow_r{
      width: 22px;
      height: 47px;
      cursor: pointer;
    }
    .arrow_r{
      transform: rotate(180deg);
    }
  }
  .indexList{
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 15px;
    .indexItem{
      width: 23px;
      height: 23px;
      line-height: 23px;
      text-align: center;
      background: #9B9B9B;
      border-radius: 50%;
      font-size: 12px;
      font-family: Arial;
      font-weight: 400;
      color: #FFFFFF;
      cursor: pointer;
      margin-right: 15px;
    }
    .indexItem.active{
      background: #0085CC;
    }
  }
}
</style>
